package com.qianyu.project.web.controller.wh;

import com.qianyu.project.service.wh.QualityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("GetList")
public class QualityController {
    @Autowired
    private QualityService qualityService;
    // 主页面查询
    @GetMapping("")
    public List<Map<String , Object>> GetList(@RequestParam Map<String,Object> m){
        String starTime = (String) m.get("starTime");
        if (starTime != null){
            String starTime1=starTime.substring(0,10);
            String endTime = (String) m.get("endTime");
            if (endTime != null){
                String endTime1=endTime.substring(0,10);
                m.put("endTime1",endTime1);
            }
            m.put("starTime1",starTime1);
        }
        return qualityService.getList(m);
    }
    // 删除
    @DeleteMapping("{personnel}")
    public void Del(@PathVariable String personnel ){
        qualityService.del(personnel);
    }
    //下拉框
    @GetMapping("/getUser")
    public List<Map<String , Object>> getUser(){
        return qualityService.getUser();
    }
    // 下拉框
    @GetMapping("/getName")
    public List<Map<String , Object>> getname(){
        return qualityService.getname();
    }
    //  添加
    @GetMapping("/add1")
    public void  add(@RequestParam Map<String,Object> m){
        String time = (String) m.get("check_date");
        String time1=time.substring(0,10);
        m.put("time1",time1);
        qualityService.add(m);
    }

    // 整改界面添加
    @GetMapping("/add2")
    public void  add2(@RequestParam Map<String,Object> m){
        String time1 = (String) m.get("check_date");
        String time2 = (String) m.get("check_date");
        String time3 = (String) m.get("check_date");
        String ask_done_date=time1.substring(0,10);
        String assign_date=time1.substring(0,10);
        String check_date=time1.substring(0,10);
        m.put("ask_done_date1",ask_done_date);
        m.put("assign_date1",assign_date);
        m.put("check_date1",check_date);
        qualityService.add2(m);
    }
    // 整改页面查询
    @GetMapping("/abarbeitung")
    public List<Map<String , Object>> getAbarbeitung(@RequestParam Map<String,Object> m){
        String starTime = (String) m.get("starTime");
        if (starTime != null){
            String starTime1=starTime.substring(0,10);
            String endTime = (String) m.get("endTime");
            if (endTime != null){
                String endTime1=endTime.substring(0,10);
                m.put("endTime1",endTime1);
            }
            m.put("starTime1",starTime1);
            System.out.println(m);
        }
        return qualityService.getAbarbeitung(m);
    }
    // 删除
    @DeleteMapping("/del/{personnel}")
    public void delete(@PathVariable String personnel ){
        qualityService.delete(personnel);
    }
    //下拉框 /getUserName
    @GetMapping("/getUserName")
    public List<Map<String , Object>> getUserName(){
        return qualityService.getUserName();
    }
}
